<template>
  <div id="app">
    <router-view></router-view>
    <TabBar v-if="$route.meta.tabBar"></TabBar>
    <FloatBall></FloatBall>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
import TabBar from "@/components/TabBar";
import FloatBall from "@/components/FloatBall";

export default {
  components: {
    TabBar,
    FloatBall,
  },
  mounted() {
    this.setTokenData();
  },
  computed: {
    ...mapState({
      data_index: (state) => state.data.index,
    }),
  },
  methods: {
    ...mapMutations(["setTokenData", "getIndexData"]),
  },
  created() {
    var IndexData = localStorage.getItem("IndexData");
    if (IndexData) {
      this.getIndexData(JSON.parse(IndexData));
    } else {
      this.axios.get("/api/index").then((response) => {
        this.getIndexData(response.data.data);
      });
    }
  },
};
</script>

<style lang="less">
body {
  background-color: #f5f5f5;
}
#app {
  max-width: 750px; /* no */
  margin: 0 auto;
  position: relative;
  div {
    box-sizing: border-box;
  }
  img {
    vertical-align: middle;
  }
  a {
    color: black;
  }
}
.van-toast {
  width: fit-content;
}
</style>
